/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.udesc.db;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author anderson
 */
@Entity
@Table(name = "logradouros")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Logradouros.findAll", query = "SELECT l FROM Logradouros l"),
    @NamedQuery(name = "Logradouros.findById", query = "SELECT l FROM Logradouros l WHERE l.id = :id"),
    @NamedQuery(name = "Logradouros.findByRua", query = "SELECT l FROM Logradouros l WHERE l.rua = :rua"),
    @NamedQuery(name = "Logradouros.findByBairro", query = "SELECT l FROM Logradouros l WHERE l.bairro = :bairro"),
    @NamedQuery(name = "Logradouros.findByCep", query = "SELECT l FROM Logradouros l WHERE l.cep = :cep")})
public class Logradouros implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "rua")
    private String rua;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "bairro")
    private String bairro;
    @Basic(optional = false)
    @NotNull
    @Column(name = "cep")
    private int cep;
    @OneToMany(mappedBy = "logradouro")
    private List<Empresas> empresasList;
    @OneToMany(mappedBy = "logradouro")
    private List<Fornecedores> fornecedoresList;
    @OneToMany(mappedBy = "logradouro")
    private List<Cliente> clienteList;
    @JoinColumn(name = "cidade", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Cidades cidade;
    @OneToMany(mappedBy = "logradouro")
    private List<Bancos> bancosList;
    @OneToMany(mappedBy = "logradouro")
    private List<Terceiros> terceirosList;

    public Logradouros() {
    }

    public Logradouros(Integer id) {
        this.id = id;
    }

    public Logradouros(Integer id, String rua, String bairro, int cep) {
        this.id = id;
        this.rua = rua;
        this.bairro = bairro;
        this.cep = cep;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getRua() {
        return rua;
    }

    public void setRua(String rua) {
        this.rua = rua;
    }

    public String getBairro() {
        return bairro;
    }

    public void setBairro(String bairro) {
        this.bairro = bairro;
    }

    public int getCep() {
        return cep;
    }

    public void setCep(int cep) {
        this.cep = cep;
    }

    @XmlTransient
    public List<Empresas> getEmpresasList() {
        return empresasList;
    }

    public void setEmpresasList(List<Empresas> empresasList) {
        this.empresasList = empresasList;
    }

    @XmlTransient
    public List<Fornecedores> getFornecedoresList() {
        return fornecedoresList;
    }

    public void setFornecedoresList(List<Fornecedores> fornecedoresList) {
        this.fornecedoresList = fornecedoresList;
    }

    @XmlTransient
    public List<Cliente> getClienteList() {
        return clienteList;
    }

    public void setClienteList(List<Cliente> clienteList) {
        this.clienteList = clienteList;
    }

    public Cidades getCidade() {
        return cidade;
    }

    public void setCidade(Cidades cidade) {
        this.cidade = cidade;
    }

    @XmlTransient
    public List<Bancos> getBancosList() {
        return bancosList;
    }

    public void setBancosList(List<Bancos> bancosList) {
        this.bancosList = bancosList;
    }

    @XmlTransient
    public List<Terceiros> getTerceirosList() {
        return terceirosList;
    }

    public void setTerceirosList(List<Terceiros> terceirosList) {
        this.terceirosList = terceirosList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Logradouros)) {
            return false;
        }
        Logradouros other = (Logradouros) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return String.format("%s, Bairro %s, %d", rua, bairro, cep);
    }
    
}
